package com.stu.consumer.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.stu.common.entity.Student;
import com.stu.common.service.StudentService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class StudentController {
    @Reference
    private StudentService studentService;

    @RequestMapping("/getAll")
    public List<Student> findAll(){
        return studentService.findAll();
    }

    @RequestMapping("/getStudent")
    public Student findStudent(Long id){
        return studentService.findById(id);
    }

    @RequestMapping("/modify")
    public Map modify(Student student){
        Map map = new HashMap();
        if(student.getId()!=null&&student.getBirthday()!=null&&student.getClassId()!=null&&student.getEmail()!=null&&student.getGender()!=null&&student.getsName()!=null&&student.getTelephone()!=null){
            studentService.modifyById(student);
            System.out.println("11111111111111111111111111");
            map.put("code",0);
            return map;
        }
        map.put("code",1);
        return map;
    }
}
